Open
Conversation
For a vector v of length n, element v[n] is not guaranteed to be NULL as vector_grow does not clear newly allocated memory. Get the length of the vector instead of checking for a NULL element. This (a) fixes a segfault when the unitialized pointer value is non-null and (b) correctly detects the root node so that a POST to /restconf/data creates a new top-level node. Signed-off-by: Eric Kinzie <ekinzie@labn.net>
Initialize the key_out string with a NULL at the beginning so that strcat() and strlen() are not confused by whatever uninitialized non-zero data happens to be there. This avoids appending =<key> when no key should be output (and it contains garbage). It also fixes the formatting of keys when strcat() has appended the first key after some uninitialized data. example from tavern-ci output: ERROR tavern.response.base:base.py:51 Value mismatch in headers: Key mismatch: (expected["location"] = 'https://192.168.1.40/cgi-bin/restconf/data/restconf-example:course/instructors' (type = <class 'tavern.util.dict_util.format_keys.<locals>.InnerFormattedString'>), actual["location"] = 'https://192.168.1.40/cgi-bin/restconf/data/restconf-example:course/instructors=*Ò¶ÿÿ' (type = <class ' str'>)) Signed-off-by: Eric Kinzie <ekinzie@labn.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi, here are a couple of trivial changes I made to get the tavern-ci tests to pass on my systems. Both deal with uninitialized memory. I tested with openwrt 18.06 on arm64.